﻿@model RoadFlow.Model.DbConnection
<form method="post">
    @Html.AntiForgeryToken()
    <br />
    <table cellpadding="0" cellspacing="1" border="0" width="99%" class="formtable">
        <tr>
            <th style="width: 80px;">连接名称：</th>
            <td>
                <input type="hidden" name="Id" value="@Model.Id" />
                <input type="hidden" name="Sort" value="@Model.Sort" />
                <input type="text" name="Name" id="Name" class="mytext" value="@Model.Name" validate="empty" style="width: 75%" />
            </td>
        </tr>
        <tr>
            <th>连接类型：</th>
            <td>
                <select id="connType" class="myselect" name="connType" validate="empty">
                    <option value=""></option>
                    @Html.Raw(ViewData["connTypeOptions"])
                </select>
            </td>
        </tr>
        <tr>
            <th>连接字符串：</th>
            <td>
                <textarea class="mytext" name="ConnString" cols="1" rows="1" validate="empty" style="width: 75%; height: 100px;">@Model.ConnString</textarea>
            </td>
        </tr>
        <tr>
            <th>备注：</th>
            <td>
                <textarea class="mytext" name="Note" cols="1" rows="1" style="width: 95%; height: 50px;">@Model.Note</textarea>
            </td>
        </tr>
    </table>
    <div class="buttondiv">
        <input type="button" value="确定保存" class="mybutton" onclick="checkform(this);" />
        <input type="button" class="mybutton" value="取消关闭" style="margin-left: 5px;" onclick="closewin();" />
    </div>
    <script type="text/javascript">
        var win = new RoadUI.Window();
        $(window).load(function ()
        {
        });
        function closewin()
        {
            win.close();
            return false;
        }
        function checkform(but)
        {
            var f = document.forms[0];
            if (new RoadUI.Validate().validateForm(f))
            {
                var o = RoadUI.Core.serializeForm($(f));
                $(but).prop("disabled", true);
                $.ajax({
                    url: "SaveEdit@(Html.Raw(ViewData["queryString"]))", data: o, type: "post", success: function (text)
                    {
                        if (RoadUI.Core.checkLogin(text, false))
                        {
                            alert(text);
                        }
                        $(but).prop("disabled", false);
                        win.reloadOpener();
                        win.close();
                    }
                });
            }
        }
    </script>
</form>